home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / FULLSYN / FULLS.C < prev   
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.8 KB  |  54 lines

  1. // Dynamic link library implementation of NeuroSolutions FullSynapse component 
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /*************************************************************/
  6. /* Macros to access the PE layers and weights in matrix form */
  7.  
  8. #define in(i,j)        input[j+i*inCols]
  9. #define out(i,j)    output[j+i*outCols]
  10. #define W(i,j)        weights[j+i*inCount]
  11.  
  12. /***********************************/
  13. /* Forward activation of component */
  14.  
  15. __declspec(dllexport) void performFullSynapse(
  16.     DLLData *instance,    // Pointer to instance data (may be NULL)
  17.     NSFloat    *input,     // Pointer to the input layer of processing elements (PEs)
  18.     int     inRows,        // Number of rows of PEs in the input layer
  19.     int     inCols,        // Number of columns of PEs in the input layer
  20.     NSFloat    *output,     // Pointer to the output layer
  21.     int     outRows,    // Number of rows of PEs in the output layer
  22.     int     outCols,    // Number of columns of PEs in the output layer
  23.     NSFloat    *weights     // Pointer to the fully connected matrix of weights
  24.     )
  25. {
  26.     int    i, j,
  27.         inCount=inRows*inCols,
  28.         outCount=outRows*outCols;
  29.  
  30.     for (i=0; i<outCount; i++)
  31.         for (j=0; j<inCount; j++)
  32.             output[i] += W(i,j)*input[j]; 
  33. }
  34.  
  35. /******************************************/
  36. /* Management of instance data (OPTIONAL) */
  37. /*
  38. __declspec(dllexport) DLLData *allocFullSynapse(
  39.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  40.     int     inRows,        // Number of rows of PEs in the input layer
  41.     int     inCols,        // Number of columns of PEs in the input layer
  42.     int     outRows,    // Number of rows of PEs in the output layer
  43.     int     outCols        // Number of columns of PEs in the output layer
  44.     )
  45. {
  46.     DLLData *instance = allocDLLInstance(oldInstance);
  47.     return instance;
  48. }
  49.  
  50. __declspec(dllexport) void freeFullSynapse(DLLData *instance)
  51. {
  52.     freeDLLInstance(instance);
  53. }
  54. */